class Solution
{
public:
    uint32_t reverseBits(uint32_t n)
    {
        if (n == 0u)
        {
            return 0u;
        }
        unsigned int result = 0u;
        int i = 32;
        while (n)
        {
            result = (result << 1) + (n & 1);
            n = n >> 1;
            --i;
        }
        result = result << i;
        return result;
    }
};